package cn.yanhu.kuwanapp.welfare

import android.content.Context
import android.content.Intent
import cn.woochen.comlib.BaseActivity
import cn.woochen.comlib.util.FragmentManagerHelper
import cn.yanhu.kuwanapp.R
import cn.yanhu.kuwanapp.databinding.ActivityVideoBinding
import cn.yanhu.kuwanapp.event.VideoFinishEvent
import cn.yanhu.kuwanapp.home.MainViewModel
import com.jeremyliao.liveeventbus.LiveEventBus

/**
 *类描述：好兔视频
 *@author woochen
 *@time 2021/8/6 11:03
 */
class VideoActivity : BaseActivity<ActivityVideoBinding,MainViewModel>() {


    private val mFragmentManagerHelper by lazy {
        FragmentManagerHelper(supportFragmentManager,R.id.fl_container)
    }

    override fun setContentView(): Int = R.layout.activity_video

    override fun initData() {
        mFragmentManagerHelper.replaceFragmentAllowingStateLoss(VideoFragment.newInstance())
    }

    override fun initListener() {
        mBinding.ivClose.setOnClickListener {
            back()
        }
    }

    companion object {

        fun start(context: Context) {
            val intent = Intent(context, VideoActivity::class.java)
            context.startActivity(intent)
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        LiveEventBus.get(VideoFinishEvent::class.java).post(VideoFinishEvent())
    }
}